<template>
  <div>

    <!-- 根据code的状态来显示那个菜单 -->
    <el-card class="box-card">
      <div class="text item">
        <div id="tableBox" style="margin:0 25px;">
          <el-table :data="tableData.tableData.data" border append>
            <el-table-column label="订单号" fixed>
              <template scope="scope">
                <span>{{ scope.row.orderNumber }}</span>
              </template>
            </el-table-column>
            <el-table-column label="付款金额">
              <template scope="scope">
                <span>{{ scope.row.payMoney| toFixed2}}元</span>
              </template>
            </el-table-column>
            <el-table-column label="经手人">
              <template scope="scope">
                <span>{{ scope.row.handling}}</span>
              </template>
            </el-table-column>
            <el-table-column label="付款时间">
              <template scope="scope">
                <span>{{getDate(scope.row.payDate) }}</span>
              </template>
            </el-table-column>
            <el-table-column label="付款状态">
              <template scope="scope">
                <span>{{ scope.row.checkStatusString}}</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" fixed="right">
              <template scope="scope">
                <el-button size="mini"  type="success" v-if="scope.row.checkStatus==0&&userType!='1'" @click.native="setCode($event)" :data-id="scope.row.id">审核</el-button>
                <el-button size="mini"  type="success" v-if="scope.row.checkStatus==2" @click.native="setCode($event)" :data-id="scope.row.id">编辑</el-button>
                <el-button size="mini"  type="info" @click.native="setCode($event)" :data-id="scope.row.id">查看</el-button>

              </template>

            </el-table-column>
          </el-table>
          <el-table :data='tableData.moneySum' border>
            <el-table-column label="已通过的付款金额合计(元)：">
              <template scope="scope">
                <span>{{ scope.row.checkSum | toFixed2}}</span>
              </template>

            </el-table-column>
            <el-table-column label="融资总金额(元)：">
              <template scope="scope">
                <span>{{ scope.row.sum | toFixed2}}</span>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </el-card>

      <div class="block" style="text-align: center;margin-top: 15px;position:relative;">
		    <pagination v-on:refreshSeachData="seachData()"  :tableData="tableData.tableData" :searchForm="searchForm"></pagination>
		</div>

  </div>

</template>

<script>
  import AddOrCompileBill from './AddOrCompileBill';
  import AuditBill from './AuditBill'
  import agentHttp from '@/utils/agentHttp.js'
  import {
    timestampToTime,
    formatTimer
  } from '@/utils/index.js'
  import pagination from '@/views/pagination'  //分页组件

  export default {
    data() {
      return {
        code: '默认',
        tableData: {
          tableData:{
            data:[]
          },
          moneySum: []
        },

      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate(valid => {
          if (valid) {
            alert("submit!");
            this.dialogSendData.dialogFormVisible = false;
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.dialogSendData.dialogFormVisible = false;
      },
      setCode(e) {
        const obj = {}
        obj.id = e.currentTarget.dataset.id
        obj.value = 'child' + e.currentTarget.outerText;
        this.$emit('setButtonCode', obj)
      },
      initData() { //初始化数据
        agentHttp.get(`adminApi/admin/mortgage_order_remit/view_list/${this.carOrderId}`).then((res) => {
          if (res.success) {
            this.tableData = Object.assign({}, this.tableData, res.data);
            this.tableData.moneySum = [{
              checkSum: res.data.checkSum,
              sum: res.data.sum
            }] //ele 表格规则必须传个数组进去

            //还有一个层数据我没有拿的
          }
        })
      },
      getDate(time) {
        return timestampToTime(time)
      },
    },
    props: {
      carOrderId: {
        type: Number
      },
      buttonValue: {
        type: String
      },
      userType: {
        type: Number
      }
    },
    mounted() {
      this.initData()
     
    },
    components: {
      AddOrCompileBill,
      AuditBill,
      pagination
    }
  };

</script>

<style lang="scss" scoped>
  .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }

  .clearfix:after {
    clear: both;
  }

  .box-card {
    margin-top: 20px;
  }

  .align {
    margin: 50px auto 0;
    text-align: center;
  }

</style>

